{% load static %}
<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <title>{% block title %}{{ system_title }}{% endblock %}</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="{% static 'css/bootstrap.min.css' %}">
    <link rel="stylesheet" href="{% static 'dashboard.css' %}">
    <link rel="stylesheet" href="{% static 'dashboard-theme.css' %}">
    <link rel="stylesheet" href="{% static 'css/bootstrap-icons.css' %}">
    <style>
        .header-bar {
            background: #3b4cca;
            color: #fff;
            padding: 1rem 2rem;
            display: flex;
            align-items: center;
            justify-content: space-between;
            box-shadow: 0 2px 8px rgba(0,0,0,0.04);
        }
        .header-bar h2 {
            margin: 0;
            font-size: 1.5rem;
            font-weight: 600;
        }
        .logout {
            color: #fff;
            background: #2a357a;
            border-radius: 6px;
            padding: 6px 18px;
            text-decoration: none;
            font-weight: 500;
            transition: background 0.2s;
        }
        .logout:hover {
            background: #232e3c;
        }
        .main-content {
            flex: 1;
            padding: 2rem;
            background: #f4f6fa;
        }
        .dropdown-menu {
            background: #fff;
            border: 1px solid #ddd;
            border-radius: 6px;
            box-shadow: 0 4px 12px rgba(0,0,0,0.15);
            min-width: 120px;
        }
        .dropdown-item {
            color: #333;
            padding: 8px 16px;
        }
        .dropdown-item:hover {
            background: #f8f9fa;
            color: #333;
        }
        @media (max-width: 768px) {
            .dashboard-container {
                flex-direction: column;
            }
            .sidebar {
                width: 100%;
                min-width: unset;
                padding: 1rem 0;
            }
            .main-content {
                padding: 1rem;
            }
        }
    </style>
</head>
<body>
    <div class="header-bar">
        <h2>{% block header %}{{ system_title }}后台{% endblock %}</h2>
        {% if request.user.is_authenticated %}
        <div class="dropdown" style="position:relative;">
            <a href="#" class="btn btn-link text-white dropdown-toggle" id="userDropdown" data-bs-toggle="dropdown" aria-expanded="false" style="font-weight:600;">
                {% if request.user.profile and request.user.profile.realname %}
                    {{ request.user.profile.realname }}
                {% else %}
                    {{ request.user.username }}
                {% endif %}
            </a>
            <ul class="dropdown-menu dropdown-menu-end" aria-labelledby="userDropdown">
                <li><a class="dropdown-item" href="/change_password/">修改密码</a></li>
                <li><a class="dropdown-item" href="/logout/">退出登录</a></li>
            </ul>
        </div>
        {% endif %}
    </div>
    <div class="dashboard-container">
        {% include 'sidebar.html' %}
        <main class="main-content">
            <section>
                {% if messages %}
                {% for message in messages %}
                <script>alert("{{ message|escapejs }}");</script>
                {% endfor %}
                {% endif %}
                {% block content %}{% endblock %}
            </section>
        </main>
    </div>
    <!-- Bootstrap JavaScript -->
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>
